package com.bzchao

//定义一个闭包赋值给变量
def running = { who ->
    println("${who} running start")
    println("${who} running end")
}

// 两种定义方式
running("张三")
running.call("张三")

def running2(Closure closure) {
    println(" running start")
    closure()
    println(" running end")
}

//闭包作为最后一个参数，闭包可以写在方法外
running2({ println("running2 ...") })
running2 { println("running2 ...") }

def running3(Closure closure) {
    println(" running start")
    closure(1, 2)
    println(" running end")
}

running3 { a, b -> println("running3 ${a + b}") }
